home *** CD-ROM | disk | FTP | other *** search
/ AM/FM: Amiga Musicians' Freeware Magazine 4 / AM-FM 4.adf / TechCorner / audiotest.c < prev   
C/C++ Source or Header  |  1991-11-16  |  898b  |  32 lines

  1. #include <exec/types.h>
  2. #include <hardware/custom.h>
  3. #include <hardware/dmabits.h>
  4. #include <stdio.h>
  5.  
  6. /* This would work even without prototypes, but... */
  7. extern LONG AllocChannels(void);
  8. extern void FreeChannels(void);
  9.  
  10. /* This is a simple pulse waveform */
  11. static UBYTE chip pulse[] = { -128,-128,-128,-128,127,127,127,127 };
  12.  
  13. extern struct Custom far custom; /* for audio hardware access */
  14.  
  15. void main()
  16. {
  17.     printf("AM/FM Synthetic sound generator V0.0001\n");
  18.     if(AllocChannels()) {
  19.         printf("Sorry, but the audio channels are in use.\n");
  20.         return;
  21.     }
  22.     /* Now the channels are ours, exclusively */
  23.     custom.aud[0].ac_ptr = (UWORD *)pulse;
  24.     custom.aud[0].ac_len = 4;
  25.     custom.aud[0].ac_per = 852;
  26.     custom.aud[0].ac_vol = 40;
  27.     custom.dmacon = DMAF_SETCLR|DMAF_AUD0; /* Audio 0 DMA on */
  28.     Delay(50); /* annoy the user for one second */
  29.     custom.dmacon = DMAF_AUD0; /* DMA off */
  30.     FreeChannels();
  31. }
  32.